package com.lx.dynamicdatasouce.mybatis.demo.controller;

import com.lx.dynamicdatasouce.mybatis.demo.entity.User;
import com.lx.dynamicdatasouce.mybatis.demo.service.IDemoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author lX
 * @version JDK 8
 * @className DemoController (此处以class为例)
 * @date 2024/10/7
 * @description 测试controller
 */
@RestController
@RequestMapping("demo")
@Slf4j
public class DemoController {


    @Autowired
    private IDemoService demoService;


    @GetMapping(value = "select")
    public List<User> select(){
        return demoService.list();
    }


    @GetMapping(value = "insert")
    public String insert(){
        User user = new User();
        user.setName("luoxue");
        demoService.save(user);
        return "数据添加成功";
    }


}
